package cs3343.project.family.testing;

import static org.junit.Assert.*;

import javax.swing.ImageIcon;

import cs3343.project.family.*;
import cs3343.project.family.Character;

import org.junit.Test;

public class DiceTest {

	// test whether EndGame* all player 1200 esteem
	@Test
	public void endGameTest1() {
		
		int numPlayer=3;
		int esteemPt=1200;

        String proimgPath = ConfigManager.IMAGE_PATH + "profilePic1" + ".jpg";
        String iconimgPath = ConfigManager.IMAGE_PATH + "char1" + ".jpg";
        char gender='M';
   
        StartGame start=new StartGame();
        InitGame init=new InitGame();
        
        start.selectedPlayer=numPlayer;
        Character player = new Character("Player",gender,8, new ImageIcon(proimgPath), new ImageIcon(iconimgPath),esteemPt);
        
        for (int i=0;i<numPlayer;i++){
        	start.character[i]=player;
        	start.character[i].setEsteem(esteemPt);
        }

		DiceController dice= new DiceController();
		dice.isEndGame();

		//boolean result=EndGame.f.isShowing();
		boolean result=init.getGameFrame().isShowing();
		
		assertEquals(result,false);
		
	}
	
	//Modify at 16/3 4am
	// test whether EndGame* a player has 100 esteem
	@Test
	public void endGameTest2() {
		
		int numPlayer=3;
		int oriesteemPt=300;
		
        // players' general setting
		String proimgPath = ConfigManager.IMAGE_PATH + "profilePic1" + ".jpg";
        String iconimgPath = ConfigManager.IMAGE_PATH + "char1" + ".jpg";
        char gender='F';
        StartGame start=new StartGame();
        InitGame init=new InitGame();
        
        start.selectedPlayer=numPlayer;
    	StartGame.selectedPlayer=numPlayer;
    	
        Character player = new Character("Player",gender,5, new ImageIcon(proimgPath), new ImageIcon(iconimgPath),oriesteemPt);
        
        // set first two player with >1000 esteem
        for (int i=0;i<numPlayer;i++){
			StartGame.character[i]=player;
        	StartGame.character[i].setEsteem(1320);
        }
        // set last character has esteem <1000
        StartGame.character[numPlayer-1].setEsteem(100);
        
		DiceController dice= new DiceController();
		dice.isEndGame();

		
		boolean result=init.getGameFrame().isShowing();

		assertEquals(result,true);
		
	}
	
	

}
